/**
 * Created by zhaomi on 16/4/27.
 */
var conn=require('../conf/mysql')
module.exports={
    getAllStudentsByClassroom:function(grade,classroom,cb){
        var options={
            sql: 'select student.id,username,name from student,classroom where grade=? and classroom=? and student.class=classroom.id',
            params: [grade,classroom],
            handle: function(student){
                cb(student)
            }
        }
        conn.execQuery(options)
    },
    getAllStudentsByClassId:function(classId,cb){
        var options={
            sql: 'select student.id,student.username,student.name,sex,grade,classroom,teacher.name as classTeacher from student,classroom,user,teacher where student.class=? and student.class=classroom.id and student.username=user.username and classroom.class_teacher=teacher.id',
            params: [classId],
            handle: function(student){
                cb(student)
            }
        }
        conn.execQuery(options)
    },
}